package com.bamboo.framework.framework.security.controller;


import com.bamboo.framework.framework.security.service.IRoleMenuService;
import com.bamboo.framework.common.format.ReturnMsg;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 菜单角色关联表 前端控制器
 * </p>
 *
 * @author 郭晴
 * @since 2018-12-19
 */
@RestController
@RequestMapping("/roleMenu")
public class RoleMenuController {

  @Resource
  private IRoleMenuService iRoleMenuService;

  /**
   * 根据角色id获取当前关联的菜单集合
   *
   * @param roleId 角色Id
   */
  @GetMapping("getRoleMenuByRoleId")
  public ReturnMsg getRoleMenuByRoleId(@RequestParam String roleId) {
    return iRoleMenuService.getRoleMenuIdByRoleId(roleId);
  }


  /**
   * 关联角色和菜单
   *
   * @param map 参数信息，里面包括（roleId角色id，String）+（menus菜单集合list）
   */
  @PostMapping("saveMenus")
  public ReturnMsg saveMenu(@RequestBody Map<String, Object> map) {
    return iRoleMenuService.saveMenu(map);
  }

}
